<?php
class  Module_CallCenter_Socket
{
    //通话类型
    public static $call_type = [
        'dialout' => "callout",
        'normal' => "call",
        'transfer' => "transfercall",
        'dialTransfer' => "dialTransfercall",
    ];
    //坐席cno转换。方便前段
    public static function changeCno($function,$data){
        if(!isset($data['cno'])){
            return $data;
        }
        $change_data = [
            'calloutHandler' => 'FromExten',
            'unlinkHandler' => 'Agent',
            'SignOutHandler' => 'exten',
            'SignInHandler' => 'exten'
        ];
        $data[$change_data[$function]] = $data['cno'];
        unset($data['cno']);
        return $data;
    }


    //外呼
    public static function calloutHandler($data){
        return Module_CallCenter_Call::getInstance()->dialout(self::changeCno(__FUNCTION__,$data));
    }
    //挂机
    public static function unlinkHandler($data){
        return Module_CallCenter_Call::getInstance()->hangup(self::changeCno(__FUNCTION__,$data));
    }
    //签出
    public static function SignOutHandler($data){
        return Module_CallCenter_Call::getInstance()->SignOut(self::changeCno(__FUNCTION__,$data));
    }
    //签入
    public static function SignInHandler($data){
        return Module_CallCenter_Call::getInstance()->SignIn(self::changeCno(__FUNCTION__,$data));
    }
}